package model

import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.layout.HorizontalLayout
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.windows.WindowOwner
import org.uqbar.commons.model.ObservableUtils
import templates.AgregarNuevo
import templates.MyOwnSimpleWindow
import java.util.List

class EditarPaisView extends MyOwnSimpleWindow<Pais> {
	@Property val AgregarNuevo template = new AgregarNuevo
	@Property val List<Pais> paisesConexiones
	
	new(WindowOwner owner, Pais pais, List<Pais> paisesParaConexiones){
		super(owner, pais)
		this._paisesConexiones = paisesParaConexiones
		
	}
	
	override createContents(Panel mainPanel){
	this.setTitle("Editar Pais")
	mainPanel.setLayout(new VerticalLayout)
	
	val panel1 = new Panel(mainPanel)
			.setLayout(new HorizontalLayout)
			
	
	this.template.labelAndBox(panel1,"Nombre", "nombre")
	ObservableUtils.firePropertyChanged(modelObject, "nombre", modelObject.nombre)
	
				
	this.template.caracteristicaBundle(mainPanel, "Características", "caracteristicas", [| new EditarCaracteristicasView(owner, this.modelObject).open])
	this.template.caracteristicaBundle(mainPanel, "Conexiones", "conexionesAereas", [|new EditarConexionesView(owner, this.modelObject, paisesConexiones).open])
	this.template.caracteristicaBundle(mainPanel, "Lugares de Interes", "lugaresInteresantes", [|new EditarLugaresView(owner, this.modelObject).open])
	
	val panel2 = new Panel(mainPanel).setLayout(new ColumnLayout(2))
	
	new Button(panel2) => [
		setCaption("Aceptar")
		setWidth(120)
		onClick[| close ]
		]
	}
	
}